#
#   PowerUp.py
#
#   This program is free software; you can redistribute it and/or modify
#   it under the terms of the GNU General Public License as published by
#   the Free Software Foundation; version 2 of the License.
#
#   This program is distributed in the hope that it will be useful,
#   but WITHOUT ANY WARRANTY; without even the implied warranty of
#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#   GNU General Public License for more details.
#
#   Copyright
#   Author: Salvatore S. Gionfriddo
#   Contributors: Nicholas F. Hoover
#   Created: 2007.07.04
#   Last Modified: 2007.07.24
#

from GameObject import GameObject
from Animation import Animation
from Effect import DrugEffect, PizzaEffect, TacosEffect, HungerBoost, HealthBoost, HeartBurn

class PowerUp(GameObject):
    
##############
# ANIMATIONS #
##############
    NUM_ANIMATIONS = 9
    
    (DRUGS, PIZZA, INDIAN, TACOS,
     DEAD_BASIC_KID, DEAD_FAST_KID, DEAD_STRONG_KID, DEAD_FAT_KID, DEAD_WEAK_KID) = range(NUM_ANIMATIONS)
    
    LEFT = NUM_ANIMATIONS

    INDIAN_FRAME_TICKS = 15
    
    ###################
    # ANIMATION TABLE #
    ###################
    ANIMATION_TABLE = [
        #'Real' Powerups
        (DRUGS,         'Drugs',  1, Animation.NO_KEY_FRAME),
        (PIZZA,         'Pizza',  1, Animation.NO_KEY_FRAME),
        (INDIAN,        'Indian', INDIAN_FRAME_TICKS, Animation.NO_KEY_FRAME),
        (TACOS,         'Tacos',  1, Animation.NO_KEY_FRAME),

        #Dead Kid Powerups
        (DEAD_BASIC_KID,         'BasicKid_Dead',  1, Animation.NO_KEY_FRAME),
        (DEAD_FAST_KID,          'FastKid_Dead',   1, Animation.NO_KEY_FRAME),
        (DEAD_STRONG_KID,        'StrongKid_Dead', 1, Animation.NO_KEY_FRAME),
        (DEAD_FAT_KID,           'FatKid_Dead',    1, Animation.NO_KEY_FRAME),
        (DEAD_WEAK_KID,          'WeakKid_Dead',   1, Animation.NO_KEY_FRAME),
        ]

    DEFAULT_ANIMATION = DRUGS

    #############
    # MOVEMENTS #
    #############
    MOVEMENTS = [ (0,0), (0,0) ]    #SITTIN
    
########
# MISC #
########
    RECT_SIZE = (40, 40)
    TICKS_TO_LIVE = 30*60 #last for 1 minute?
    
    def __init__(self, facing, powerUpType = DRUGS):
        GameObject.__init__(self)
        self.currentAnimation = powerUpType + facing
        self.facing = facing
        self.effects = []
        self.ticksLeft = PowerUp.TICKS_TO_LIVE
        if powerUpType == PowerUp.DRUGS:
            effect = DrugEffect()
        elif powerUpType == PowerUp.PIZZA:
            effect = PizzaEffect()
        elif powerUpType == PowerUp.INDIAN:
            effect = HungerBoost()
            self.effects.append(HeartBurn())
        elif powerUpType == PowerUp.TACOS:
            effect = HungerBoost()
            self.effects.append(TacosEffect())
        elif powerUpType == PowerUp.DEAD_BASIC_KID:
            effect = HungerBoost()
            self.effects.append(HealthBoost())
            self.RECT_SIZE = (50,30)
        elif powerUpType == PowerUp.DEAD_FAST_KID:
            effect = HungerBoost()
            self.effects.append(HealthBoost())
            self.RECT_SIZE = (50,30)
        elif powerUpType == PowerUp.DEAD_STRONG_KID:
            effect = HungerBoost()
            self.effects.append(HealthBoost())
            self.RECT_SIZE = (50,30)
        elif powerUpType == PowerUp.DEAD_WEAK_KID:
            effect = HungerBoost()
            self.effects.append(HealthBoost())
            self.RECT_SIZE = (50,30)
        elif powerUpType == PowerUp.DEAD_FAT_KID:
            effect = HungerBoost()
            self.effects.append(HealthBoost())
            self.RECT_SIZE = (50,30)
        self.effects.append(effect)
        self.update()
        
    def isDeadKid(self):
        return self.getAnimationType() >= PowerUp.DEAD_BASIC_KID

    def isDrugs(self):
        return self.getAnimationType() == PowerUp.DRUGS

    def getType(self):
        return self.getAnimationType()

    def update(self):
        self.ticksLeft -= 1
        if self.ticksLeft == 0:
            self.kill()
        else:
            GameObject.update(self)
